home *** CD-ROM | disk | FTP | other *** search
/ Univers Interactif 3 / INTERACTIF.BIN / pc / planeten / internet / macslip2.6up / MacSLIP Folder / Annex.script next >
Text File  |  1995-01-11  |  7KB  |  322 lines

  1. #
  2. # Annex.script
  3. #
  4. # You may need to modify this script to work with your particular
  5. # Annex configuration.
  6. #
  7. # This script is designed to dial a Hayes compatible modem.
  8. #
  9. # The first time this script runs, it will prompt for your username,
  10. # password, and phone number to dial. These settings will be saved
  11. # for subequent connections.
  12. #
  13. # Using default settings, the modem will be initialized before this script
  14. # starts running. Make sure the "Init modem when connecting" option
  15. # is set in the "Modem" menu and that you have made an appropriate
  16. # modem selection.
  17. #
  18. ignore var busygo
  19.  
  20. # If user is not defined, ask for it.
  21. ifdef user goto skipuser
  22. message ""
  23. message "\bEnter your login username."
  24. ask var
  25. define user "$var"
  26. label skipuser
  27.  
  28. # if password is not defined, ask for it
  29. ifdef password goto skippass
  30. message "Will login to SLIP server as $user.\n\bPassword:"
  31. askp var
  32. define /h password "$var"
  33. label skippass
  34.  
  35. # if phone is not defined, ask for it
  36. ifdef phone goto skipphone
  37. message "\bEnter the phone number to dial"
  38. ask var
  39. define phone "$var"
  40. label skipphone
  41.  
  42. # Let the user know we're starting up
  43. label startup
  44. message "Script starting..."
  45. # Setup action handlers
  46. on restart goto restart
  47. on abort goto abort
  48.  
  49. # Dial the phone and wait for the terminal server to send its login
  50. # banner. Some areas support using *70 as a dialing prefix to suppress
  51. # call-waiting tones which will probably cause your modem
  52. # to lose the connection. Some terminal servers may require you to
  53. # autobaud before they will respond. Allow enough time for the modem
  54. # handshake to complete.
  55.  
  56. label dial
  57.  
  58. ifdef INITMODEM goto skipwarn
  59. beep
  60. message "\bYou should select a modem using Configure"
  61. label skipwarn
  62.  
  63. message "Dialing $phone..."
  64. flush
  65. on abort goto hangupabort
  66. send "ATDT $phone\r"
  67. {
  68.     ifmatch "Username:" break
  69.     ifmatch "Login:" break
  70.     ifmatch "login:" break
  71.     ifmatch "CONNECT" break
  72.     ifmatch "NO DIALTONE" goto nodialtone
  73.     ifmatch "NO DIAL TONE" goto nodialtone
  74.     ifmatch "BUSY" goto phonebusy
  75.     ifmatch "NO CARRIER" goto nocarrier
  76.     iftime 1:15 goto dialtimeout
  77. }
  78.  
  79. delay 2
  80. setcount 0 0
  81. label wakeannex
  82. flush
  83. ifcountgt 0 20 goto hangup
  84. delay 1
  85. send "\r"
  86. {
  87.     ifmatch "annex:" break
  88.     ifmatch "name:" goto loginbegin
  89.     iftime 3 goto wakeannex
  90. }
  91. send "\r"
  92. delay 2
  93. {
  94.     ifmatch "name:" goto loginbegin
  95.     ifmatch "annex:" break
  96.     iftime 30 goto hangup
  97. }
  98.  
  99. # Log into the SLIP server. Try three times to send the username. Use
  100. # counter #1 to count the number of login attempts.
  101.  
  102. label loginbegin
  103. setcount 1 0
  104. label login
  105. ifcountgt 1 3 goto cantlogin
  106. message "Logging in as $user..."
  107. setcount 0 0
  108. label user
  109. flush
  110. ifcountgt 0 3 goto baduser
  111. send "$user\r"
  112. {
  113.     ifmatch "Password:" break
  114.     ifmatch "password:" break
  115.     ifmatch "name:" goto user
  116.     ifmatch "login:" goto user
  117.     ifmatch "Login:" goto user
  118.     iftime 10 goto baduser
  119. }
  120.  
  121. # Send the password and wait for the prompt. If we see the
  122. # username prompt again, then we didn't get logged in so try again.
  123.  
  124. message "Sending password..."
  125. flush
  126. send "$password\r"
  127. {
  128.     ifmatch "Access denied" goto accessdenied
  129.     ifmatch "incorrect" goto accessdenied
  130.     ifmatch "Incorrect" goto accessdenied
  131.     ifmatch ">" goto setslip
  132.     ifmatch "%" goto setslip
  133.     ifmatch "Annex:" goto setslip
  134.     ifmatch "annex:" goto setslip
  135.     iftime 10 goto cantlogin
  136. }
  137.  
  138. # If the login attempt fails, we land here.  We can take whatever
  139. # action is necessary to get another login prompt.
  140.  
  141. label accessdenied
  142. {
  143.     ifmatch "name:" goto login
  144.     ifmatch "Login:" goto login
  145.     ifmatch "login:" goto login
  146.     ifmatch "NO CARRIER" goto cantlogin
  147.     iftime 10 goto cantlogin
  148. }
  149.  
  150. # enable SLIP mode
  151. label setslip
  152. send "slip\r"
  153. {
  154.     ifmatch "Your address is" break
  155.     iftime 15 goto cantstartslip
  156. }
  157.  
  158. # Wait for the entire line to output, then parse the gateway
  159. # and IP addresses from the annex output.
  160.  
  161. message "Parsing IP addresses..."
  162. {
  163.     iftime 2 break
  164. }
  165. ipfind IPGWADDRESS IPADDRESS
  166.  
  167. # All done.  Send message to alert the user, flush the junk out of the
  168. # receive buffer, and return success.
  169.  
  170. message "Script complete"
  171. flush
  172. return 1
  173.  
  174. # Error handlers.
  175.  
  176. label abort
  177. beep
  178. message "\bCommand-. seen or Cancel button clicked."
  179. goto aborted
  180.  
  181. label hangupabort
  182. beep
  183. message "\bCommand-. seen or Cancel button clicked."
  184. goto hangup
  185.  
  186. label cantfindmodem
  187. beep
  188. message "\bThe modem didn't respond to attention"
  189. message "\bbsignal.  Check modem and cabling."
  190. goto aborted
  191.  
  192. label cantinitmodem
  193. beep
  194. message "\bThe modem didn't respond to initialization"
  195. message "\bstring.  Check the modem."
  196. goto aborted
  197.  
  198. label nodialtone
  199. beep
  200. message "\bThe modem could not detect a dialtone."
  201. message "\bCheck the phone line."
  202. goto aborted
  203.  
  204. label phonebusy
  205. flush
  206. message "\bThe number $phone is busy."
  207. if $busygo eq "go" goto redial
  208. on restart goto busygo
  209. beep
  210. message "\bClick "Restart" to keep trying, "OK" to quit."
  211. ask junk
  212. return 0
  213.  
  214. label busygo
  215. on restart goto restart
  216. set busygo "go"
  217. flush
  218. label redial
  219. do syncmodem
  220. goto dial
  221.  
  222. label nocarrier
  223. beep
  224. message "\bThe modem could not establish a connection."
  225. message "\bMake sure there is a modem on the other end."
  226. goto aborted
  227.  
  228. label dialtimeout
  229. message "\bThe modem or SLIP server isn't responding."
  230. message "\bTry dialing manually to make sure the modem"
  231. message "\band SLIP server are OK."
  232. goto aborted
  233.  
  234. label baduser
  235. beep
  236. message "\bThe SLIP server won't accept a username."
  237. message "\bTry dialing manually to make sure the SLIP"
  238. message "\bserver is OK."
  239. goto hangup
  240.  
  241. label cantlogin
  242. beep
  243. message "\bLogin to SLIP server failed, check username"
  244. message "\band password."
  245. goto hangup
  246.  
  247. label cantsetterm
  248. beep
  249. message "\bCan't set terminal line for SLIP operation."
  250. goto hangup
  251.  
  252. label cantstartslip
  253. beep
  254. message "\bCan't put server into SLIP mode."
  255. goto hangup
  256.  
  257. # General back-end for bailing out.
  258.  
  259. label hangup
  260. do disconnect
  261. # fallthrough into aborted
  262.  
  263. label aborted
  264. message "\bScript aborted!"
  265. message "\bClick "OK" to quit, "Restart" to retry."
  266. # This activates the OK button.
  267. ask junk
  268. flush
  269. return 0
  270.  
  271. # Restart procedure.
  272. # This label is entered when you click the restart button in the
  273. # connection dialog. We try to force the modem to hang up, then we go back
  274. # to the start of the script.
  275.  
  276. label restart
  277. do disconnect
  278. message "\bScript restarted."
  279. goto startup
  280.  
  281. # Disconnect procedure. The "disconect" procedure is called by MacSLIP
  282. # when the "Disconnect" button is clicked. This procedure escapes the
  283. # modem into command mode and hangs up the phone. The +++ escape sequence
  284. # is surrounded by delays that some modems require.
  285.  
  286. label disconnect
  287. send "\d\d+++\d\dATH\r\d\d"
  288. do syncmodem
  289. return 1
  290.  
  291. # Alternate disconnect procedure for modems that drop into command mode
  292. # when DTR is dropped. You may want to try this alternate disconnect
  293. # procedure if the one above doesn't work for your modem. Just swap the
  294. # labels to use this one instead of the one above.
  295.  
  296. label disconnect2
  297. dtr off
  298. delay 3
  299. send "ATH\r"
  300. dtr on
  301. flush
  302. return 1
  303.  
  304. # Attempt to sync up with the modem, but don't wait forever.
  305. label syncmodem
  306. setcount 4 0
  307. flush
  308. label waitmodem2
  309. ifcountgt 4 2 return
  310. send "AT\r"
  311. {
  312.     ifmatch "OK" break
  313.     iftime 2 goto waitmodem2
  314. }
  315. flush
  316. return
  317.  
  318. # for Emacs
  319. #  Local Variables:
  320. #  tab-width: 4
  321. #  End:
  322.